package com.rampage.entity.role;

import com.rampage.entity.IdEntity;
import com.rampage.entity.user.User;

import javax.persistence.*;
import java.util.Set;

/**
 * 角色
 * Created by wujingwei on 2017/12/18.
 */
@Entity
@Table(name = "t_role")
public class Role extends IdEntity{

    private String name;

    private boolean enable;

    private Set<User> users;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "t_user_role", joinColumns = {@JoinColumn(name = "role_id")}, inverseJoinColumns = {@JoinColumn(name = "user_id")})
    @OrderBy("id")
    public Set<User> getUsers() {
        return users;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }
}
